#include "input_manager.h"
#include <string.h>
#include<stdio.h>
#include<stdlib.h>
static int StdinGetInput(char *event);
static T_InputEventOpr g_tStdinOpr = {
    .name = "stdin",
    .GetInput = StdinGetInput
    
};

int StdinGetInput(char *event)
{
    char e;

    do
    {
        e = getchar();
    } while ((e != 'n') && (e != 'u') && (e != 'q'));

    if (e == 'n')
    {
        *event = 'n';
        return 0;
    }
    else if (e == 'u')
    {
        *event = 'u';
        return 0;
    }
    else
    {
        *event = 'q';
        return 0;
    }
}

int StdinInit()
{   
    g_tStdinOpr.event = (char*) malloc(1);
    // *(g_tStdinOpr.event) ='\0';
    return RegisterInputEventOpr(&g_tStdinOpr);
}